package com.mbv5;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.mbv5.utils.SesionFacoryUtil;

/**
 * Created by qiao on 2017/1/2.
 */
public class MybatisDemo {
    static SqlSession sqlSession = null;

    @BeforeClass
    public static void before() {
        sqlSession = SesionFacoryUtil.getSqlSessionIntance();
        System.out.println(sqlSession);
        //每次都是新建一个SqlSession实例org.apache.ibatis.session.defaults.DefaultSqlSession@dc57db
    }

    @AfterClass
    public static void after() {
        sqlSession.close();
    }

    @Test
    public void loadEnv() {
        System.out.println("begin");
        String statement = "com.mbv5.dao.Apply.list";
        List<Map<String, Object>> rs = sqlSession.selectList(statement);
        System.out.println(rs);
    }

    @Test
    public void simple() throws IOException {
        List<Map<String, String>> rs = sqlSession.selectList("com.mbv5.dao.Apply.list");
        System.out.println(rs);
    }
}
